#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double db;

const int N = 1e5 + 5;

int T;
int n, m, L, V;
int ans1, ans2;
int p[N], tot;
bitset<N> vis;

struct Seg{
    int l, r;

    Seg(){}

    Seg(int x, int y){
        l = x, r = y;
    }
} s[N];

Seg Calc(int di, int vi, int ai){
    if(!ai){
        if(vi <= V)
            return Seg(-1, -1);
        return Seg(di, L);
    }

    if(ai < 0 && vi <= V)
        return Seg(-1, -1);

    if(ai > 0 && vi > V)
        return Seg(di, L);

    db tmp = di + (1ll * V * V - 1ll * vi * vi) / (2.0 * ai);
    if(tmp < di + 1){
        if(ai < 0) return Seg(di, di);
        return Seg(di + 1, L);
    }

    if(ai < 0) return Seg(di, tmp - 1);
    return Seg(tmp + 1, L);
}

void Check(Seg u){
    if(u.l == -1 || u.r == -1 || u.l > u.r) return ;
    s[++tot] = u;
}

bool Find(int pos){
    auto u = s[pos];
    int id = lower_bound(p + 1, p + m + 1, u.l) - p;

    if(id > m || id < 1 || p[id] > u.r || p[id] < u.l) return 0;
    return 1;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);

	cin >> T;
	while(T--){
        cin >> n >> m >> L >> V;

        int d, v, a;
        for(int i = 1; i <= n; i++){
            cin >> d >> v >> a;
            Check(Calc(d, v, a));
        }
        p[m + 1] = 0;
        for(int i = 1; i <= m; i++){
            cin >> p[i];
        }
        sort(p + 1, p + m + 1);
        sort(s + 1, s + tot + 1, [](Seg& x, Seg& y){ return x.r < y.r; });

        for(int i = 1; i <= tot; i++){
            vis[i] = Find(i);

            if(vis[i]) ans1++;
        }

        ans2 = m;
        int lst = 0, j = 1;
        for(int i = 1; i <= tot; i++){
            if(!vis[i]) continue;
            if(lst && p[lst] >= s[i].l && p[lst] <= s[i].r) continue;

            while(j <= m && p[j] <= s[i].r) j++;
            if(j > m || p[j] > s[i].r) j--;

            ans2--;
            lst = j;
        }

        cout << ans1 << ' ' << ans2 << '\n';

        ans1 = ans2 = 0;
        tot = 0;
        vis.reset();
	}

	return 0;
}
